package com.net.shop.car.manager.api.volley.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.Area;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;
import com.net.shop.car.manager.utils.LogUtils;

public class CityResponse extends Response {

	public CityResponse() {
		super(Constants.CITY);
		// TODO Auto-generated constructor stub
	}

	private List<Area> city = new ArrayList<Area>();

	public List<Area> getProvince() {
		return city;
	}

	@Override
	public String getContentTag() {
		// TODO Auto-generated method stub
		return "city";
	}

	@Override
	public void parseContent(String content) {
		// TODO Auto-generated method stub
		try {
			JSONArray jsonArray = new JSONArray(content);
			int len = jsonArray.length();
			for (int i = 0; i < len; i++) {
				JSONObject jsonObject = jsonArray.getJSONObject(i);
				String name = jsonObject.getString("NAME");
				String id = jsonObject.getString("ID");
				city.add(new Area(name, id));
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			LogUtils.e(e.getMessage());
		}

	}
}
